/**
 * 
 */
package xupt.se.ttms.view.employee;


import javax.script.ScriptContext;
import javax.swing.BorderFactory;
import javax.swing.DefaultButtonModel;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

import xupt.se.ttms.dao.EmployeeDAO;
import xupt.se.ttms.model.Customer;
import xupt.se.ttms.model.Employee;
import xupt.se.ttms.model.Movie;
import xupt.se.ttms.model.Order;
import xupt.se.ttms.model.Play;
import xupt.se.ttms.model.Seat;
import xupt.se.ttms.model.Studio;
import xupt.se.ttms.model.Ticket;
import xupt.se.ttms.service.CustomerSrv;
import xupt.se.ttms.service.EmployeeSrv;
import xupt.se.ttms.service.MovieSrv;
import xupt.se.ttms.service.OrderSrv;
import xupt.se.ttms.service.PlaySrv;
import xupt.se.ttms.service.SeatSrv;
import xupt.se.ttms.service.StudioSrv;
import xupt.se.ttms.service.TicketSrv;
import xupt.se.ttms.view.customer.CustomerAddUI;
import xupt.se.ttms.view.customer.CustomerUpdateUI;
import xupt.se.ttms.view.employee.Confirms.MovieTableSelectionListener;
import xupt.se.ttms.view.movie.InsertMovie;
import xupt.se.ttms.view.movie.UpdateMovie;
import xupt.se.ttms.view.play.PlayAddUI;
import xupt.se.ttms.view.play.PlayUpdateUI;

import xupt.se.ttms.view.seat.SeatUpdateUI;
import xupt.se.ttms.view.studio.StudioAddUI;
import xupt.se.ttms.view.studio.StudioUpdateUI;
import xupt.se.ttms.view.tmpl.Login;

import java.awt.Color;
import java.awt.Image;
import java.awt.Insets;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;

/**
 * @author Administrator
 *
 */

public class Employee_MainUITmpl{
	public static String user="";
	public static JFrame frame;
	public static String Data[];
	public static JLabel label = new JLabel();
	public static JLabel label1 = new JLabel();
	public static String infor;
	public static JTable jTable =null;
	
	public static Movie movie=null;
	public static Studio studio=null;
	public static Employee employee=null;
	public static Customer customer=null;
	public static Ticket ticket=null;
	public static Seat seat=null;
	public static Play play=null;
	public static String comboBoxselect="";
	
	public Employee_MainUITmpl(String s) {
		frame = new JFrame();
		if(jTable!=null)
			jTable.updateUI();
		// TODO Auto-generated method stub
		user = s;
		frame.setLayout(null);
		frame.setTitle("框架");
		ImageIcon icon=new ImageIcon("img/2.png");
		JLabel a = new JLabel(icon);
		a.setLayout(null);
		frame.setLayout(null);
		icon.setImage(icon.getImage().getScaledInstance(850,70,Image.SCALE_DEFAULT));
		frame.add(a);
		a.setBounds(0,0,850,70);
		JLabel users = new JLabel("用    户    名:   "+user);
		a.add(users);
		users.setBounds(670,10,150,20);
		JButton btnModPwd = new JButton("修改密码");
		btnModPwd.setFocusPainted(false) ;
		btnModPwd.setBounds(670, 35, 60, 20);
		btnModPwd.setMargin(new Insets(0,0,0,0));
		btnModPwd.setContentAreaFilled(false);
		btnModPwd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				frame.dispose();
				Employee_ChangePassWord a= new Employee_ChangePassWord(user);
			}
		});
		a.add(btnModPwd);
		JButton btnModPwd1 = new JButton("注销");
		btnModPwd1.setFocusPainted(false) ;
		btnModPwd1.setBounds(740, 35, 40, 20);
		btnModPwd1.setMargin(new Insets(0,0,0,0));
		btnModPwd1.setContentAreaFilled(false);
		btnModPwd1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				frame.dispose();
				Login s =new Login();
			}
		});
		a.add(btnModPwd1);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        init(frame);
        frame.setBounds(0, 0, 850, 500);
        // 窗体大小不能改变
        frame.setResizable(false);
        // 居中显示
        frame.setLocationRelativeTo(null);
        // 窗体可见
        frame.setVisible(true);
	}
	public static void init(JFrame frame){
	
		jTable=new JTable();
		JScrollPane scroll =new  JScrollPane(jTable);
		scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 
		scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 
		scroll.setBounds(220,105,620,280);
		frame.add(scroll);
		label.setLayout(null);
		label.setBounds(0, 100, 850, 300);
		label1.setLayout(null);
		label1.setBounds(-1, 400, 850, 100);
		label1.setBorder(BorderFactory.createLineBorder(Color.gray));
		frame.add(label1);
		JButton btnModPwd = new JButton("影片管理");
		btnModPwd.setFocusPainted(false) ;
		btnModPwd.setBounds(0, 70, 142, 30);
		btnModPwd.setMargin(new Insets(0,0,0,0));
		btnModPwd.setContentAreaFilled(false);
		frame.add(btnModPwd);
		Data = new String[4];
		Data[0]="热映影片";
		Data[1] = "最新上映";
		Data[2] = "推荐影片";
		Data[3] = "全部影片";
		MovieSrv movieSrv=new MovieSrv();
		Movie movie=new Movie();
		List<Movie> list=new ArrayList<>();
		try {
			
			list=movieSrv.FetchHot((float)2.0);
			Confirms.setMovieTable(list);
		} catch (Exception e1) {
			// TODO 自动生成的 catch 块
			e1.printStackTrace();
		}
		Side(Data,frame);
		down("请输入影片名称");
		btnModPwd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				
				Data = new String[4];
				Data[0]="热映影片";
				Data[1] = "最新上映";
				Data[2] = "推荐影片";
				Data[3] = "全部影片";
				MovieSrv movieSrv=new MovieSrv();
				Movie movie=new Movie();
				List<Movie> list=new ArrayList<>();
				try {
					
					list=movieSrv.FetchHot((float)2.0);
					Confirms.setMovieTable(list);
				} catch (Exception e1) {
					// TODO 自动生成的 catch 块
					e1.printStackTrace();
				}
				Side(Data,frame);
				down("请输入影片名称");			
			}
		});
		JButton btnModPwd1 = new JButton("售票管理");
		btnModPwd1.setFocusPainted(false) ;
		btnModPwd1.setBounds(142, 70, 142, 30);
		btnModPwd1.setMargin(new Insets(0,0,0,0));
		btnModPwd1.setContentAreaFilled(false);
		frame.add(btnModPwd1);
		btnModPwd1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
			
				Data = new String[1];
				Data[0] = "订单";
				TicketSrv ticketSrv=new TicketSrv();
				Ticket ticket=new Ticket();
				List<Ticket> list=new ArrayList<>();
				try {
					list=ticketSrv.FetchAll();
					Confirms.setTicketTable(list);
				} catch (Exception e2) {
					// TODO: handle exception
				}
				Side(Data,frame);
				down1("请输入票ID");
			}
		});
		JButton btnModPwd2 = new JButton("演出厅管理");
		btnModPwd2.setFocusPainted(false) ;
		btnModPwd2.setBounds(284, 70, 142, 30);
		btnModPwd2.setMargin(new Insets(0,0,0,0));
		btnModPwd2.setContentAreaFilled(false);
		frame.add(btnModPwd2);
		btnModPwd2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
			
				Data = new String[3];
				Data[0]="小型演出厅";
				Data[1] = "大型演出厅";		
				Data[2] = "全部演出厅";
				StudioSrv studioSrv=new StudioSrv();
				Studio studio=new Studio();
				List<Studio> list=new ArrayList<>();
				try {
					list=studioSrv.FetchAll();
					Confirms.setStudioTable(list);
				} catch (Exception e2) {
					// TODO: handle exception
				}
				Side(Data,frame);
				down2("请输入演出厅ID");
			}
		});
		JButton btnModPwd3 = new JButton("用户管理");
		btnModPwd3.setFocusPainted(false) ;
		btnModPwd3.setBounds(426, 70, 142, 30);
		btnModPwd3.setMargin(new Insets(0,0,0,0));
		btnModPwd3.setContentAreaFilled(false);
		frame.add(btnModPwd3);
		btnModPwd3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				
				Data = new String[4];
				Data[0]="当前用户";
				Data[1] = "普通用户";
				Data[2] = "VIP用户";
				Data[3] = "全部用户";
				EmployeeSrv employeeSrv=new EmployeeSrv();
				Employee employee=new Employee();
				List<Employee> list=new ArrayList<>();
				 
				try {
					list=employeeSrv.Fetch(Employee_MainUITmpl.user);
					Confirms.setEmployeeTable(list);
				} catch (Exception e2) {
					// TODO: handle exception
				}
				Side(Data,frame);
				down3("请输入用户账号");
			}
		});
		JButton btnModPwd5 = new JButton("座位");
		btnModPwd5.setFocusPainted(false) ;
		btnModPwd5.setBounds(568, 70, 142, 30);
		btnModPwd5.setMargin(new Insets(0,0,0,0));
		btnModPwd5.setContentAreaFilled(false);
		frame.add(btnModPwd5);
		btnModPwd5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				Data = new String[3];
				Data[0]="全部座位";
				Data[1] = "损坏座位";
				Data[2]="清空座位";
				SeatSrv seatSrv=new SeatSrv();
				Seat seat=new Seat();
				List<Seat> list=new ArrayList<>();
				 
				try {
					list=seatSrv.FetchAll();
					Confirms.setSeatTable(list);
				} catch (Exception e2) {
					// TODO: handle exception
				}
				Side(Data,frame);
				down4("请输入演出厅ID");
			}
		});
		JButton btnModPwd4 = new JButton("演出计划");
		btnModPwd4.setFocusPainted(false) ;
		btnModPwd4.setBounds(710, 70, 133, 30);
		btnModPwd4.setMargin(new Insets(0,0,0,0));
		btnModPwd4.setContentAreaFilled(false);
		frame.add(btnModPwd4);
		btnModPwd4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				Data = new String[1];
				Data[0]="刷新";
				
				PlaySrv playSrv=new PlaySrv();
				Play play=new Play();
				List<Play> list=new ArrayList<>();
				 
				try {
					list=playSrv.FetchAll();
					Confirms.setPlayTable(list);
				} catch (Exception e2) {
					// TODO: handle exception
				}
				Side(Data,frame);
				down5("请输入电影ID");
			}
		});
	}
	//左边的布局
	public static void Side(String Date[],JFrame frame){
		int i;
		int t=2;
		label.removeAll();
		for(i=0;i<Date.length;i++){
			JButton btnModPwd = new JButton(Date[i]);
			Confirms aa = new Confirms();
			btnModPwd.setFocusPainted(false) ;
			btnModPwd.setBounds(0, t, 212, 60);
			t += 62;
			btnModPwd.setMargin(new Insets(0,0,0,0));
			btnModPwd.setContentAreaFilled(false);
			btnModPwd.addActionListener(aa);
			label.add(btnModPwd);
		}
		frame.add(label);
		frame.repaint();
	}
	//最下面的布局
	public static void down(String s){
		label1.removeAll();
		infor = s;
		JLabel lel = new JLabel(s);
		lel.setBounds(20,15,100,30);
		label1.add(lel);
		JTextField text = new JTextField();
		text.setBounds(120,20,150,20);
		label1.add(text);
		JButton btnModPwd3 = new JButton("Search");
		btnModPwd3.setFocusPainted(false) ;
		btnModPwd3.setBounds(290, 20, 60, 20);
		btnModPwd3.setMargin(new Insets(0,0,0,0));
		btnModPwd3.setContentAreaFilled(false);
		label1.add(btnModPwd3);
		btnModPwd3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {	
				MovieSrv movieSrv=null;
				Movie movie=null;
				List<Movie> list=null;
				if(text.getText().equals(""))
				{
					JOptionPane.showConfirmDialog(null, "请输入影片名称");
				}
				else
				{
					movieSrv=new MovieSrv();
					movie=new Movie();
					list=new ArrayList<>();
					try {
						
						//list=movieSrv.Fetch(text.getText());
						list=movieSrv.FetchFuzzy(text.getText());
						Confirms.setMovieTable(list);
						
					} catch (Exception e1) {
						// TODO 自动生成的 catch 块
						e1.printStackTrace();
					}
				}								
				
			}
		});
		JButton btnModPwd4 = new JButton("ShowPlan");
		btnModPwd4.setFocusPainted(false) ;
		btnModPwd4.setBounds(380, 20, 60, 20);
		btnModPwd4.setMargin(new Insets(0,0,0,0));
		btnModPwd4.setContentAreaFilled(false);
		label1.add(btnModPwd4);
		btnModPwd4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				
				if(Employee_MainUITmpl.movie!=null)
				{
					MovieSrv movieSrv=new MovieSrv();
					PlaySrv playSrv=new PlaySrv();
					List<Movie> movies=new ArrayList<>();
					List<Play> plays=new ArrayList<>();
					try {
						movies=movieSrv.Fetch(Employee_MainUITmpl.movie.getMv_id());
						if(movies.size()<1)
						{
							return ;
						}
						plays=playSrv.FetchMv_id(movies.get(0).getMv_id());
						if(plays.size()<1)
						{
							return ;
						}
						Confirms.setPlayTable(plays);
					} catch (Exception e) {
						// TODO 自动生成的 catch 块
						e.printStackTrace();
					}			

				}
				else {
					JOptionPane.showConfirmDialog(null, "请选定数据");
				}
				
				
			
			}
		});
		JButton btnModPwd5 = new JButton("AddPlan");
		btnModPwd5.setFocusPainted(false) ;
		btnModPwd5.setBounds(480, 20, 60, 20);
		btnModPwd5.setMargin(new Insets(0,0,0,0));
		btnModPwd5.setContentAreaFilled(false);
		label1.add(btnModPwd5);
		btnModPwd5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
			
				if(Employee_MainUITmpl.movie!=null)
				{
					MovieSrv movieSrv=new MovieSrv();
					
					try {
						frame.dispose();
						PlayAddUI addUI=new PlayAddUI(Employee_MainUITmpl.movie,user);
					} catch (Exception e) {
						// TODO 自动生成的 catch 块
						e.printStackTrace();
					}
				}
				else {
					JOptionPane.showConfirmDialog(null, "请选定数据");
				}
				
				
			}
		});
		JButton btnModPwd = new JButton("Add");
		btnModPwd.setFocusPainted(false) ;
		btnModPwd.setBounds(570, 20, 60, 20);
		btnModPwd.setMargin(new Insets(0,0,0,0));
		btnModPwd.setContentAreaFilled(false);
		label1.add(btnModPwd);
		btnModPwd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
		
					frame.dispose();
					InsertMovie t = new InsertMovie(user);
				
				/*else if(infor.equals("请输入用户账号"))
				{
					frame.dispose();
					CustomerAddUI customerAddUI=new CustomerAddUI(user);
				}*/
				
			}
		});
		JButton btnModPwd1 = new JButton("Modify");
		btnModPwd1.setFocusPainted(false) ;
		btnModPwd1.setBounds(660, 20, 60, 20);
		btnModPwd1.setMargin(new Insets(0,0,0,0));
		btnModPwd1.setContentAreaFilled(false);
		label1.add(btnModPwd1);
		btnModPwd1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				
				if(Employee_MainUITmpl.movie!=null)
				{
					frame.dispose();
					UpdateMovie employee_UpdateMovie=new UpdateMovie(user,Employee_MainUITmpl.movie);
				}
				else
				{
					JOptionPane.showConfirmDialog(null, "请选定数据");
				}
				/*else if(infor.equals("请输入用户账号"))
				{
					if(Employee_MainUITmpl.customer!=null)
					{
						frame.dispose();
						CustomerUpdateUI customerUpdateUI=new CustomerUpdateUI(user,Employee_MainUITmpl.customer);
					}
					else {
						JOptionPane.showConfirmDialog(null, "请选定数据");
					}
					
				}*/
			}
		});
		JButton btnModPwd2 = new JButton("Delete");
		btnModPwd2.setFocusPainted(false) ;
		btnModPwd2.setBounds(740, 20, 60, 20);
		btnModPwd2.setMargin(new Insets(0,0,0,0));
		btnModPwd2.setContentAreaFilled(false);
		label1.add(btnModPwd2);
		btnModPwd2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				
					if(Employee_MainUITmpl.movie!=null)
					{
						MovieSrv movieSrv=new MovieSrv();
						try {
							movieSrv.delete(Employee_MainUITmpl.movie.getMv_id());
						} catch (Exception e) {
							// TODO 自动生成的 catch 块
							e.printStackTrace();
						}
					}
					else
					{
						JOptionPane.showConfirmDialog(null, "请选定数据");
					}
					
				
				
				/*else if(infor.equals("请输入票ID"))
				{
					if(Employee_MainUITmpl.order!=null)
					{
						OrderSrv orderSrv=new OrderSrv();
						try {
							orderSrv.delete(Employee_MainUITmpl.order.getOrder_id());
						} catch (Exception e) {
							// TODO 自动生成的 catch 块
							e.printStackTrace();
						}
					}
					else {
						JOptionPane.showConfirmDialog(null, "请选定数据");
					}
					
				}*/
				
				
				//movieSrv.delete(ID)
			}
		});
		label1.repaint();
	}
	public static void down1(String s){
		label1.removeAll();
		JLabel lel = new JLabel(s);
		lel.setBounds(210,15,100,30);
		label1.add(lel);
		JTextField text = new JTextField();
		text.setBounds(280,20,150,20);
		label1.add(text);
		JButton btnModPwd1 = new JButton("Search");
		btnModPwd1.setFocusPainted(false) ;
		btnModPwd1.setBounds(450, 20, 75, 20);
		btnModPwd1.setMargin(new Insets(0,0,0,0));
		btnModPwd1.setContentAreaFilled(false);
		label1.add(btnModPwd1);
		btnModPwd1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				TicketSrv ticketSrv=null;
				Ticket ticket=null;
				List<Ticket> list=null;
				if(text.getText().equals(""))
				{
					JOptionPane.showConfirmDialog(null, "请输入票ID");
				}
				else
				{
					ticketSrv=new TicketSrv();
					ticket=new Ticket();
					list=new ArrayList<>();
					try {
						
						list=ticketSrv.Fetch(Integer.parseInt(text.getText()));
						Confirms.setTicketTable(list);
						
					} catch (Exception e1) {
						// TODO 自动生成的 catch 块
						e1.printStackTrace();
					}
				}							
			}
		});
		
		label1.repaint();
	}
	public static void down2(String s){
		label1.removeAll();
		JLabel lel = new JLabel(s);
		lel.setBounds(100,15,100,30);
		label1.add(lel);
		JComboBox<String> studio_name=new JComboBox<>();
		StudioSrv studioSrv=new StudioSrv();
		List<Studio> list=new ArrayList<>();
		try {
			list=studioSrv.FetchAll();
		} catch (Exception e1) {
			// TODO 自动生成的 catch 块
			e1.printStackTrace();
		}
		if(list.size()>0)
		{
			for (Studio studio : list) {
				studio_name.addItem(studio.getName());
			}
		}
		
		studio_name.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent arg0) {
				comboBoxselect=arg0.getItem().toString();
				
			}
		});
		JLabel a2=new JLabel("演出厅选择:");
		a2.setBounds(300,160,50,25);
		label1.add(a2);
		studio_name.setBounds(190,20,150,20);
		comboBoxselect=(String) studio_name.getSelectedItem();
		label1.add(studio_name);
		JButton btnModPwd1 = new JButton("Search");
		btnModPwd1.setFocusPainted(false) ;
		btnModPwd1.setBounds(360, 20, 75, 20);
		btnModPwd1.setMargin(new Insets(0,0,0,0));
		btnModPwd1.setContentAreaFilled(false);
		btnModPwd1.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				StudioSrv studioSrv=null;
				Studio studio=null;
				List<Studio> list=null;
				comboBoxselect=studio_name.getSelectedItem().toString();
				if(comboBoxselect.equals(""))
				{
					JOptionPane.showConfirmDialog(null, "请选择演出厅ID");
				}
				else
				{
					studioSrv=new StudioSrv();
					studio=new Studio();
					list=new ArrayList<>();
					try {
						
						list=studioSrv.Fetch(comboBoxselect);
						Confirms.setStudioTable(list);
						
					} catch (Exception e1) {
						// TODO 自动生成的 catch 块
						e1.printStackTrace();
					}
				}								
				
			}
		});
		label1.add(btnModPwd1);
		JButton btnModPwd2 = new JButton("Add");
		btnModPwd2.setFocusPainted(false) ;
		btnModPwd2.setBounds(455, 20, 75, 20);
		btnModPwd2.setContentAreaFilled(false);
		btnModPwd2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent Event) {
				frame.dispose();
				StudioAddUI studioAddUI=new StudioAddUI(user);
			}
		});
		label1.add(btnModPwd2);
		JButton btnModPwd3 = new JButton("Modify");
		btnModPwd3.setFocusPainted(false) ;
		btnModPwd3.setBounds(550, 20, 75, 20);
		btnModPwd3.setContentAreaFilled(false);
		btnModPwd3.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				if(Employee_MainUITmpl.studio!=null)
				{
					frame.dispose();
					StudioUpdateUI studioUpdateUI=new StudioUpdateUI(user,Employee_MainUITmpl.studio);
				}
				else {
					JOptionPane.showConfirmDialog(null, "请选定数据");
				}
				
			}
		});
		label1.add(btnModPwd3);
		JButton btnModPwd4 = new JButton("Delete");
		btnModPwd4.setFocusPainted(false) ;
		btnModPwd4.setBounds(635, 20, 75, 20);
		btnModPwd4.setContentAreaFilled(false);
		btnModPwd4.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				if(Employee_MainUITmpl.studio!=null)
				{
					StudioSrv studioSrv=new StudioSrv();
					try {
						studioSrv.delete(Employee_MainUITmpl.studio.getID());
					} catch (Exception ex) {
						// TODO 自动生成的 catch 块
						ex.printStackTrace();
					}
				}
				else {
					JOptionPane.showConfirmDialog(null, "请选定数据");
				}
				
			}
		});
		label1.add(btnModPwd4);
	
		
		
		label1.repaint();
	}
	
	public static void down3(String s){
	label1.removeAll();
	JLabel lel = new JLabel(s);
	lel.setBounds(190,15,100,30);
	label1.add(lel);
	JTextField text = new JTextField();
	text.setBounds(280,20,150,20);
	label1.add(text);
	JButton btnModPwd1 = new JButton("Search");
	btnModPwd1.setFocusPainted(false) ;
	btnModPwd1.setBounds(450, 20, 75, 20);
	btnModPwd1.setMargin(new Insets(0,0,0,0));
	btnModPwd1.setContentAreaFilled(false);
	btnModPwd1.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			CustomerSrv customerSrv=null;
			Customer customer=null;
			List<Customer> list=null;
			if(text.getText().equals(""))
			{
				JOptionPane.showConfirmDialog(null, "请输入用户账号");
			}
			else
			{
				customerSrv=new CustomerSrv();
				customer=new Customer();
				list=new ArrayList<>();
				try {
					
					list=customerSrv.Fetch(text.getText());
					Confirms.setCustomerTable(list);
					
				} catch (Exception e1) {
					// TODO 自动生成的 catch 块
					e1.printStackTrace();
				}
			}								
			
		}
	});
	label1.add(btnModPwd1);
	JButton btnModPwd2 = new JButton("Delete");
	btnModPwd2.setFocusPainted(false) ;
	btnModPwd2.setBounds(545, 20, 75, 20);
	btnModPwd2.setContentAreaFilled(false);
	label1.add(btnModPwd2);
	btnModPwd2.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent Event) {
			if(Employee_MainUITmpl.customer!=null)
			{
				CustomerSrv customerSrv=new CustomerSrv();
				try {
					customerSrv.delete(Employee_MainUITmpl.customer.getCustomer_id());
				} catch (Exception e) {
					// TODO 自动生成的 catch 块
					e.printStackTrace();
				}
			}
			else {
				JOptionPane.showConfirmDialog(null, "请选定数据");
			}
			
		}
	});
	label1.repaint();
}
	public static void down4(String s){
	label1.removeAll();
	JLabel lel = new JLabel(s);
	lel.setBounds(190,15,100,30);
	label1.add(lel);

	JComboBox<String> studio_name=new JComboBox<>();
	StudioSrv studioSrv=new StudioSrv();
	List<Studio> list=new ArrayList<>();
	try {
		list=studioSrv.FetchAll();
	} catch (Exception e1) {
		// TODO 自动生成的 catch 块
		e1.printStackTrace();
	}
	if(list.size()>0)
	{
		for (Studio studio : list) {
			studio_name.addItem(studio.getName());
		}
	}
	
	studio_name.setBounds(280,20,150,20);
	comboBoxselect=(String) studio_name.getSelectedItem();
	label1.add(studio_name);
	
	JButton btnModPwd1 = new JButton("Search");
	btnModPwd1.setFocusPainted(false) ;
	btnModPwd1.setBounds(450, 20, 75, 20);
	btnModPwd1.setMargin(new Insets(0,0,0,0));
	btnModPwd1.setContentAreaFilled(false);
	btnModPwd1.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			SeatSrv seatSrv=new SeatSrv();
			List<Seat> seats=new ArrayList<>();
			StudioSrv studioSrv=new StudioSrv();
			List<Studio> studios=new ArrayList<>();
			comboBoxselect=studio_name.getSelectedItem().toString();
			if(comboBoxselect.trim().equals(""))
			{
				JOptionPane.showConfirmDialog(null, "请输入演出厅ID");
			}
			else
			{
				try {
					studios=studioSrv.Fetch(comboBoxselect);
					if(studios.size()<1)
					{
						return ;
					}
					seats=seatSrv.FetchStudio_id(studios.get(0).getID());
					Confirms.setSeatTable(seats);
				} catch (NumberFormatException e1) {
					// TODO 自动生成的 catch 块
					e1.printStackTrace();
				} catch (Exception e1) {
					// TODO 自动生成的 catch 块
					e1.printStackTrace();
				}
			}
		}
	});
	label1.add(btnModPwd1);
	JButton btnModPwd2 = new JButton("Modify");
	btnModPwd2.setFocusPainted(false) ;
	btnModPwd2.setBounds(545, 20, 75, 20);
	btnModPwd2.setContentAreaFilled(false);
	label1.add(btnModPwd2);
	btnModPwd2.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent Event) {

			if(Employee_MainUITmpl.seat!=null)
			{
				frame.dispose();
				SeatUpdateUI seatUpdateUI=new SeatUpdateUI(user, Employee_MainUITmpl.seat);
			
			}
			else
			{
				JOptionPane.showConfirmDialog(null, "请选定数据");
			}
			
		}
	});
	JButton btnModPwd3 = new JButton("Init");
	btnModPwd3.setFocusPainted(false) ;
	btnModPwd3.setBounds(640, 20, 75, 20);
	btnModPwd3.setContentAreaFilled(false);
	label1.add(btnModPwd3);
	btnModPwd3.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent Event) {

			comboBoxselect=studio_name.getSelectedItem().toString();
			if(!comboBoxselect.equals(""))
			{
				StudioSrv studioSrv=new StudioSrv();
				List<Studio> studios=new ArrayList<>();
				
				try {
					studios=studioSrv.Fetch(comboBoxselect);
					if(studios.size()<1)
					{
						return ;
					}
		
				}catch (Exception e) {
					// TODO 自动生成的 catch 块
					e.printStackTrace();
				}
				
				Integer row=studios.get(0).getRowCount();
				Integer col=studios.get(0).getColCount();
				Integer studio_id=studios.get(0).getID();
				SeatSrv seatSrv=new SeatSrv();
				Seat seat=new Seat();
				try {
					seatSrv.init(studio_id);
				} catch (Exception e1) {
					// TODO 自动生成的 catch 块
					e1.printStackTrace();
				}
				for(int i=1;i<row+1;i++)
				{
					for(int j=1;j<col+1;j++)
					{
						
						seat.setStudio_id(studio_id);
						seat.setRow(i);
						seat.setCol(j);
						seat.setState("正常");					
						try {
							seatSrv.add(seat);
						} catch (Exception e) {
							// TODO 自动生成的 catch 块
							e.printStackTrace();
						}
					}
				}
			
			}
			else
			{
				JOptionPane.showConfirmDialog(null, "请输入演出厅ID");
			}
			
		}
	});
	label1.repaint();
}
	public static void down5(String s){
	label1.removeAll();
	JLabel lel = new JLabel(s);
	lel.setBounds(110,15,100,30);
	label1.add(lel);
	JTextField text = new JTextField();
	text.setBounds(200,20,150,20);
	label1.add(text);
	JButton btnModPwd1 = new JButton("Search");
	btnModPwd1.setFocusPainted(false) ;
	btnModPwd1.setBounds(370, 20, 75, 20);
	btnModPwd1.setMargin(new Insets(0,0,0,0));
	btnModPwd1.setContentAreaFilled(false);
	btnModPwd1.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			
			PlaySrv playSrv=null;
			Play play=null;
			List<Play> list=null;
			if(text.getText().trim().equals(""))
			{
				JOptionPane.showConfirmDialog(null, "请输入电影ID");
			}
			else
			{
				playSrv=new PlaySrv();
				play=new Play();
				list=new ArrayList<>();
				try {
					
					list=playSrv.FetchMv_id(Integer.parseInt(text.getText().trim()));
					Confirms.setPlayTable(list);
					
				} catch (Exception e1) {
					// TODO 自动生成的	 catch 块
					e1.printStackTrace();
				}
			}								
		}
	});
	label1.add(btnModPwd1);
	JButton btnModPwd2 = new JButton("Delete");
	btnModPwd2.setFocusPainted(false) ;
	btnModPwd2.setBounds(465, 20, 75, 20);
	btnModPwd2.setContentAreaFilled(false);
	btnModPwd2.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO 自动生成的方法存根
			if(Employee_MainUITmpl.play!=null)
			{
				PlaySrv playSrv=new PlaySrv();
				try {
					playSrv.delete(Employee_MainUITmpl.play.getPlay_id());
				} catch (Exception ex) {
					// TODO 自动生成的 catch 块
					ex.printStackTrace();
				}
			}
			else
			{
				JOptionPane.showConfirmDialog(null, "请选定数据");
			}
			
		}
	});
	label1.add(btnModPwd2);
	JButton btnModPwd3 = new JButton("Modify");
	btnModPwd3.setFocusPainted(false) ;
	btnModPwd3.setBounds(560, 20, 75, 20);
	btnModPwd3.setContentAreaFilled(false);
	label1.add(btnModPwd3);
	btnModPwd3.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent Event) {
			if(Employee_MainUITmpl.play!=null)
			{
				frame.dispose();
				try {
					PlayUpdateUI playUpdateUI=new PlayUpdateUI(Employee_MainUITmpl.play,user);
				} catch (Exception e) {
					// TODO 自动生成的 catch 块
					e.printStackTrace();
				}
			}
			else
			{
				JOptionPane.showConfirmDialog(null, "请选定数据");
			}
			
		}
	});
	label1.repaint();
}

	


}
class Confirms implements ActionListener{

	public void actionPerformed(ActionEvent e){
		String buttonname=e.getActionCommand();
		
		if(buttonname.equals("热映影片"))
		{
			MovieSrv movieSrv=new MovieSrv();
			Movie movie=new Movie();
			List<Movie> list=new ArrayList<>();
			try {
				
				list=movieSrv.FetchHot((float)2.0);
				setMovieTable(list);
			} catch (Exception e1) {
				// TODO 自动生成的 catch 块
				e1.printStackTrace();
			}
			
		}
		else  if (buttonname.equals("最新上映")) {
			MovieSrv movieSrv=new MovieSrv();
			Movie movie=new Movie();
			List<Movie> list=new ArrayList<>();
			try {
				
				list=movieSrv.FetchNew(2015);
				setMovieTable(list);
			
			} catch (Exception e1) {
				// TODO 自动生成的 catch 块
				e1.printStackTrace();
			}
		}
		else  if (buttonname.equals("推荐影片")) {
			MovieSrv movieSrv=new MovieSrv();
			Movie movie=new Movie();
			List<Movie> list=new ArrayList<>();
			try {
				
				list=movieSrv.FetchRecom(9.0f);
				setMovieTable(list);
			} catch (Exception e1) {
				// TODO 自动生成的 catch 块
				e1.printStackTrace();
			}
		}
		else  if (buttonname.equals("全部影片")) {
			MovieSrv movieSrv=new MovieSrv();
			Movie movie=new Movie();
			List<Movie> list=new ArrayList<>();
			try {
				
				list=movieSrv.FetchAll();
				setMovieTable(list);
			} catch (Exception e1) {
				// TODO 自动生成的 catch 块
				e1.printStackTrace();
			}
		}
		else if (buttonname.equals("小型演出厅")) {
			StudioSrv studioSrv=new StudioSrv();
			Studio studio=new Studio();
			List<Studio> list=new ArrayList<>();
			try {
				list=studioSrv.FetchSmall(100);
				setStudioTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		else if (buttonname.equals("大型演出厅")) {
			StudioSrv studioSrv=new StudioSrv();
			Studio studio=new Studio();
			List<Studio> list=new ArrayList<>();
			try {
				list=studioSrv.FetchBig(300);
				setStudioTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		else if (buttonname.equals("全部演出厅")) {
			StudioSrv studioSrv=new StudioSrv();
			Studio studio=new Studio();
			List<Studio> list=new ArrayList<>();
			try {
				list=studioSrv.FetchAll();
				setStudioTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		else if (buttonname.equals("当前用户")) {
			EmployeeSrv employeeSrv=new EmployeeSrv();
			Employee employee=new Employee();
			List<Employee> list=new ArrayList<>();
			 
			try {
				list=employeeSrv.Fetch(Employee_MainUITmpl.user);
				setEmployeeTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		else if (buttonname.equals("普通用户")) {
			CustomerSrv customerSrv=new CustomerSrv();
			Customer customer=new Customer();
			List<Customer> list=new ArrayList<>();
			try {
				list=customerSrv.FetchNormal("normal");
				setCustomerTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		else if (buttonname.equals("VIP用户")) {
			CustomerSrv customerSrv=new CustomerSrv();
			Customer customer=new Customer();
			List<Customer> list=new ArrayList<>();
			try {
				list=customerSrv.FetchVip("vip");
				setCustomerTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		else if (buttonname.equals("全部用户")) {
			CustomerSrv customerSrv=new CustomerSrv();
			Customer customer=new Customer();
			List<Customer> list=new ArrayList<>();
			try {
				list=customerSrv.FetchAll();
				setCustomerTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}

		else if (buttonname.equals("订单")) {
			TicketSrv ticketSrv=new TicketSrv();
			Ticket ticket=new Ticket();
			List<Ticket> list=new ArrayList<>();
			try {
				list=ticketSrv.FetchAll();
				setTicketTable(list);
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		else if (buttonname.equals("刷新")) {
			PlaySrv playSrv=new PlaySrv();
			Play play=new Play();
			List<Play> plays=new ArrayList<>();
			try {
				plays=playSrv.FetchAll();
				setPlayTable(plays);
			} catch (Exception e1) {
				// TODO 自动生成的 catch 块
				e1.printStackTrace();
			}
			
		} 
		else if (buttonname.equals("全部座位")) {
			SeatSrv seatSrv=new SeatSrv();
			Seat seat=new Seat();
			List<Seat> seats=new ArrayList<>();
			try {
				seats=seatSrv.FetchAll();
				setSeatTable(seats);
			} catch (Exception e1) {
				// TODO 自动生成的 catch 块
				e1.printStackTrace();
			}
		}
		else if (buttonname.equals("损坏座位")) {
			SeatSrv seatSrv=new SeatSrv();
			Seat seat=new Seat();
			List<Seat> seats=new ArrayList<>();
			try {
				seats=seatSrv.Fetch("损坏");
				setSeatTable(seats);
			} catch (Exception e1) {
				// TODO 自动生成的 catch 块
				e1.printStackTrace();
			}
		}
		else if (buttonname.equals("清空座位")) {
			int result=JOptionPane.showConfirmDialog(null, "请再次确定是否清空座位信息");
			if(result==0)
			{
				SeatSrv seatSrv=new SeatSrv();		
				try {
					seatSrv.deleteAll();
				} catch (Exception e1) {
					// TODO 自动生成的 catch 块
					e1.printStackTrace();
				}
			}
			else
			{
				
			}
		
		}
	}
	
	public static void setEmployeeTable(List<Employee> list) {
		
			System.out.println(list.get(0).getClass().getSimpleName());
			Vector<Vector<String> > data=new Vector<>();
			Vector<String> datarow=null;
			Vector<String> columns=new Vector<>();
			String[] columnsName={"员工ID,账号,名称,密码,工作名,电话"};
			columns.add("员工ID");
			columns.add("账号");
			columns.add("名称");
			columns.add("密码");
			columns.add("工作名");
			columns.add("电话");
			if(list.size()!=0)
			{
				for (Employee employee : list) {
					datarow=new Vector<>();
					datarow.add(String.valueOf(employee.getId()));
					datarow.add(String.valueOf(employee.getAccess()));
					datarow.add(String.valueOf(employee.getName()));
					datarow.add(String.valueOf(employee.getPassword()));
					datarow.add(String.valueOf(employee.getcName()));
					datarow.add(String.valueOf(employee.getTel()));
											
					data.add(datarow);
				}
			}
			
			JTable jTable=Employee_MainUITmpl.jTable;
			Confirms confirms=new Confirms();
			
			EmployeeTableSelectionListener listener =confirms.new EmployeeTableSelectionListener(jTable);
			jTable.getSelectionModel().addListSelectionListener(listener);
			
			jTable.setRowHeight(25);
			jTable.setAutoscrolls(true);
			//jTable.getColumnModel().getColumn(0).setPreferredWidth(200);
			DefaultTableModel model=new  DefaultTableModel();
			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			model.setColumnCount(6);
			
			model.setDataVector(data, columns);		
		
			jTable.setModel(model);
			/*
			jTable.getColumnModel().getColumn(0).setPreferredWidth(110);
			jTable.getColumnModel().getColumn(1).setPreferredWidth(110);
			jTable.getColumnModel().getColumn(2).setPreferredWidth(110);
			jTable.getColumnModel().getColumn(3).setPreferredWidth(110);
			jTable.getColumnModel().getColumn(4).setPreferredWidth(110);
			jTable.getColumnModel().getColumn(5).setPreferredWidth(110);
			*/
		
		
	}

	public static void setMovieTable(List<Movie> list)
	{
			System.out.println(list.get(0).getClass().getSimpleName());
			Vector<Vector<String> > data=new Vector<>();
			Vector<String> datarow=null;
			Vector<String> columns=new Vector<>();
			String[] columnsName={"电影ID,电影名称,电影评分,导演,主演,类型,时长,上映年份,介绍，电影图片"};
			columns.add("电影ID");
			columns.add("电影名称");
			columns.add("电影评分");
			columns.add("导演");
			columns.add("主演");
			columns.add("类型,");
			columns.add("时长");
			columns.add("上映年份");
			columns.add("介绍");
			columns.add("电影图片");

			if(list.size()!=0)
			{
				for (Movie movie2 : list) {
					datarow=new Vector<>();
					datarow.add(String.valueOf(movie2.getMv_id()));
					datarow.add(String.valueOf(movie2.getName()));
					datarow.add(String.valueOf(movie2.getScore()));
					datarow.add(String.valueOf(movie2.getDirector()));
					datarow.add(String.valueOf(movie2.getActor()));
					datarow.add(String.valueOf(movie2.getType()));
					datarow.add(String.valueOf(movie2.getTime()));
					datarow.add(String.valueOf(movie2.getDate()));
					datarow.add(String.valueOf(movie2.getIntroduction()));
					datarow.add(String.valueOf(movie2.getImg()));	
					
					data.add(datarow);
				}
			}
			
			JTable jTable=Employee_MainUITmpl.jTable;
			
			Confirms confirms=new Confirms();
			MovieTableSelectionListener listener =confirms.new MovieTableSelectionListener(jTable);
			jTable.getSelectionModel().addListSelectionListener(listener);
			
			jTable.setRowHeight(25);
			//jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			jTable.setAutoscrolls(true);
			//jTable.getColumnModel().getColumn(0).setPreferredWidth(200);
			DefaultTableModel model=new  DefaultTableModel();
			model.setColumnCount(10);
			
			model.setDataVector(data, columns);		
			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
			jTable.setModel(model);
			
			jTable.getColumnModel().getColumn(0).setPreferredWidth(40);
			jTable.getColumnModel().getColumn(1).setPreferredWidth(60);
			jTable.getColumnModel().getColumn(2).setPreferredWidth(50);
			jTable.getColumnModel().getColumn(3).setPreferredWidth(80);
			jTable.getColumnModel().getColumn(4).setPreferredWidth(140);
			jTable.getColumnModel().getColumn(5).setPreferredWidth(180);
			jTable.getColumnModel().getColumn(6).setPreferredWidth(50);
			jTable.getColumnModel().getColumn(7).setPreferredWidth(60);
			jTable.getColumnModel().getColumn(8).setPreferredWidth(600);
			jTable.getColumnModel().getColumn(8).setPreferredWidth(200);
		
	}
	public static void setStudioTable(List<Studio> list)
	{
		
			System.out.println(list.get(0).getClass().getSimpleName());
			String[] columnsName={"演出厅ID,演出厅名字,演出厅行数,演出厅列数,演出厅座位数,演出厅介绍"};
			Vector<Vector<String> > data=new Vector<>();
			Vector<String> datarow=null;
			Vector<String> columns=new Vector<>();
			
			//columns=new Vector<String>(Arrays.asList(columnsName));
			columns.add("演出厅ID");
			columns.add("演出厅名字");
			columns.add("演出厅行数");
			columns.add("演出厅列数");
			columns.add("演出厅座位数");
			columns.add("演出厅介绍");
			if(list.size()!=0)
			{
				for (Studio studio : list) {
					datarow=new Vector<>();
					datarow.add(String.valueOf(studio.getID()));
					datarow.add(String.valueOf(studio.getName()));
					datarow.add(String.valueOf(studio.getRowCount()));
					datarow.add(String.valueOf(studio.getColCount()));
					datarow.add(String.valueOf(studio.getSeatnumber()));
					datarow.add(String.valueOf(studio.getIntroduction()));		
	
					data.add(datarow);
				}
			}
			
			JTable jTable=Employee_MainUITmpl.jTable;
			Confirms confirms=new Confirms();
		
			StudioTableSelectionListener listener =confirms.new StudioTableSelectionListener(jTable);
			jTable.getSelectionModel().addListSelectionListener(listener);
			
			jTable.setRowHeight(25);
			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			jTable.setAutoscrolls(true);
			//jTable.getColumnModel().getColumn(0).setPreferredWidth(200);
			DefaultTableModel model=new  DefaultTableModel();
			model.setColumnCount(6);
			
			model.setDataVector(data, columns);		
			jTable.setModel(model);
			jTable.getColumnModel().getColumn(0).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(1).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(2).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(3).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(4).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(5).setPreferredWidth(100);
		
		
	}
	
	public static void setCustomerTable(List<Customer> list)
	{
		
			System.out.println(list.get(0).getClass().getSimpleName());
			String[] columnsName={"顾客ID,名称,性别,账单,电话,账号,密码,级别"};
			Vector<Vector<String> > data=new Vector<>();
			Vector<String> datarow=null;
			Vector<String> columns=new Vector<>();
			
			//columns=new Vector<String>(Arrays.asList(columnsName));
			columns.add("顾客ID");
			columns.add("名称");
			columns.add("性别");
			columns.add("账单");
			columns.add("电话");
			columns.add("账号");
			columns.add("密码");
			columns.add("级别");
			
			if(list.size()!=0)
			{
				for (Customer customer : list) {
					datarow=new Vector<>();
					datarow.add(String.valueOf(customer.getCustomer_id()));
					datarow.add(String.valueOf(customer.getCustomer_name()));
					datarow.add(String.valueOf(customer.getCustomer_sex()));
					datarow.add(String.valueOf(customer.getCustomer_bill()));
					datarow.add(String.valueOf(customer.getCustomer_tel()));
					datarow.add(String.valueOf(customer.getCustomer_count()));		
					datarow.add(String.valueOf(customer.getCustomer_password()));	
					datarow.add(String.valueOf(customer.getCustomer_level()));	
					data.add(datarow);
				}
			}
			
			JTable jTable=Employee_MainUITmpl.jTable;
			Confirms confirms=new Confirms();
		
			CustomerTableSelectionListener listener =confirms.new CustomerTableSelectionListener(jTable);
			jTable.getSelectionModel().addListSelectionListener(listener);
			jTable.setRowHeight(25);
			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			jTable.setAutoscrolls(true);
			//jTable.getColumnModel().getColumn(0).setPreferredWidth(200);
			DefaultTableModel model=new  DefaultTableModel();
			model.setColumnCount(8);
			
			model.setDataVector(data, columns);		
			jTable.setModel(model);
			
			jTable.getColumnModel().getColumn(0).setPreferredWidth(40);
			jTable.getColumnModel().getColumn(1).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(2).setPreferredWidth(50);
			jTable.getColumnModel().getColumn(3).setPreferredWidth(80);
			jTable.getColumnModel().getColumn(4).setPreferredWidth(140);
			jTable.getColumnModel().getColumn(5).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(6).setPreferredWidth(100);
			jTable.getColumnModel().getColumn(7).setPreferredWidth(60);
	
		
	}
	public static void setTicketTable(List<Ticket> list)
	{
		
			System.out.println(list.get(0).getClass().getSimpleName());
			Vector<Vector<String> > data=new Vector<>();
			Vector<String> datarow=null;
			Vector<String> columns=new Vector<>();
			columns.add("票号ID");
			columns.add("电影名称");
			columns.add("电影时长");
			columns.add("座位行号");
			columns.add("座位列号");
			columns.add("演出时间");
			columns.add("演出厅名称");
			columns.add("票价");
			if(list.size()!=0)
			{
				for (Ticket ticket : list) {
					datarow=new Vector<>();
					datarow.add(String.valueOf(ticket.getTicket_id()));
					datarow.add(String.valueOf(ticket.getMv_name()));
					datarow.add(String.valueOf(ticket.getMv_time()));
					datarow.add(String.valueOf(ticket.getSeat_row()));
					datarow.add(String.valueOf(ticket.getSeat_col()));
					datarow.add(String.valueOf(ticket.getPlay_time()));
					datarow.add(String.valueOf(ticket.getStudio_name()));
					datarow.add(String.valueOf(ticket.getPrice()));
			
					data.add(datarow);
				}
			}
			
			JTable jTable=Employee_MainUITmpl.jTable;
			
			Confirms confirms=new Confirms();
			TicketTableSelectionListener listener =confirms.new TicketTableSelectionListener(jTable);
			jTable.getSelectionModel().addListSelectionListener(listener);
			
			jTable.setRowHeight(25);
			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			jTable.setAutoscrolls(true);
			//jTable.getColumnModel().getColumn(0).setPreferredWidth(200);
			DefaultTableModel model=new  DefaultTableModel();
			model.setColumnCount(8);
			
			model.setDataVector(data, columns);		
		
			jTable.setModel(model);
			
			/*jTable.getColumnModel().getColumn(0).setPreferredWidth(40);
			jTable.getColumnModel().getColumn(1).setPreferredWidth(50);
			jTable.getColumnModel().getColumn(2).setPreferredWidth(50);
			jTable.getColumnModel().getColumn(3).setPreferredWidth(50);
			jTable.getColumnModel().getColumn(4).setPreferredWidth(50);*/
		
		
	}
	public static void setSeatTable(List<Seat> list)
	{
		
			
			Vector<Vector<String> > data=new Vector<>();
			Vector<String> datarow=null;
			Vector<String> columns=new Vector<>();
			columns.add("座位id");
			columns.add("演出厅id");
			columns.add("行号");
			columns.add("列号");
			columns.add("状态");
			if(list.size()!=0)
			{
				for (Seat seat : list) {
					datarow=new Vector<>();
					datarow.add(String.valueOf(seat.getSeat_id()));
					datarow.add(String.valueOf(seat.getStudio_id()));
					datarow.add(String.valueOf(seat.getRow()));
					datarow.add(String.valueOf(seat.getCol()));	
					datarow.add(String.valueOf(seat.getState()));
					data.add(datarow);
				}
			
			}
			JTable jTable=Employee_MainUITmpl.jTable;
			
			Confirms confirms=new Confirms();
			SeatTableSelectionListener listener =confirms.new SeatTableSelectionListener(jTable);
			jTable.getSelectionModel().addListSelectionListener(listener);
			
			jTable.setRowHeight(25);
			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			jTable.setAutoscrolls(true);
			//jTable.getColumnModel().getColumn(0).setPreferredWidth(200);
			DefaultTableModel model=new  DefaultTableModel();
			model.setColumnCount(5);
			
			model.setDataVector(data, columns);		
		
			jTable.setModel(model);
		
		
	}
	public static void setPlayTable(List<Play> list)
	{
		
			
			Vector<Vector<String> > data=new Vector<>();
			Vector<String> datarow=null;
			Vector<String> columns=new Vector<>();
			columns.add("演出计划id");
			columns.add("电影id");
			columns.add("演出厅id");
			columns.add("演出时间");
			columns.add("价格");
			columns.add("票数");
			if(list.size()!=0)
			{
				for (Play play : list) {
					datarow=new Vector<>();
					datarow.add(String.valueOf(play.getPlay_id()));
					datarow.add(String.valueOf(play.getMv_id()));
					datarow.add(String.valueOf(play.getStudio_id()));
					datarow.add(String.valueOf(play.getPlay_time()));	
					datarow.add(String.valueOf(play.getPlay_price()));	
					datarow.add(String.valueOf(play.getTicket_count()));
					data.add(datarow);
				}
			}
			
			JTable jTable=Employee_MainUITmpl.jTable;
			
			Confirms confirms=new Confirms();
			PlayTableSelectionListener listener =confirms.new PlayTableSelectionListener(jTable);
			jTable.getSelectionModel().addListSelectionListener(listener);
			
			jTable.setRowHeight(25);
			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			jTable.setAutoscrolls(true);
			//jTable.getColumnModel().getColumn(0).setPreferredWidth(200);
			DefaultTableModel model=new  DefaultTableModel();
			model.setColumnCount(6);
			
			model.setDataVector(data, columns);		
		
			jTable.setModel(model);
		
		
	
	}
	 class  PlayTableSelectionListener implements ListSelectionListener {
			
			public   Play play=null;
			JTable jTable;    
			PlayTableSelectionListener(JTable table) {
		        this.jTable = table;
		        play=new Play();
		    }
		    @Override
		    public void valueChanged(ListSelectionEvent e) {
		        	int index = jTable.getSelectedRow();
		        	int columns=jTable.getColumnCount();
		        	
		        	if(index!=-1&&columns==5)
		        	{
		        		try {
		        			play.setPlay_id(Integer.parseInt((String)jTable.getValueAt(index, 0)));
		        			play.setMv_id(Integer.parseInt((String)jTable.getValueAt(index, 1)));
		        			play.setStudio_id(Integer.parseInt((String)jTable.getValueAt(index, 2)));
		        			play.setPlay_time((String)jTable.getValueAt(index, 3));
		        			play.setPlay_price(Float.parseFloat((String)jTable.getValueAt(index, 4)));
						
							Employee_MainUITmpl.play=new Play();
							Employee_MainUITmpl.play=play;
							System.out.println(play.getPlay_id());
						} catch (Exception e2) {
							// TODO: handle exception
						}
		        		
		        	}
		        	
		    }
		    
			

		}
	 class  SeatTableSelectionListener implements ListSelectionListener {
			
			public   Seat seat=null;
			JTable jTable;    
			SeatTableSelectionListener(JTable table) {
		        this.jTable = table;
		        seat=new Seat();
		    }
		    @Override
		    public void valueChanged(ListSelectionEvent e) {
		        	int index = jTable.getSelectedRow();
		        	int columns=jTable.getColumnCount();
		        	
		        	if(index!=-1&&columns==5)
		        	{
		        		try {
		        			seat.setSeat_id(Integer.parseInt((String)jTable.getValueAt(index, 0)));
		        			seat.setStudio_id(Integer.parseInt((String)jTable.getValueAt(index, 1)));
		        			seat.setRow(Integer.parseInt((String)jTable.getValueAt(index, 2)));
		        			seat.setCol(Integer.parseInt((String)jTable.getValueAt(index, 3)));
							seat.setState((String)jTable.getValueAt(index, 4));
							Employee_MainUITmpl.seat=new Seat();
							Employee_MainUITmpl.seat=seat;
							System.out.println(seat.getSeat_id());
						} catch (Exception e2) {
							// TODO: handle exception
						}
		        		
		        	}
		        	
		    }
		    
			

		}
	 class  MovieTableSelectionListener implements ListSelectionListener {
		
		public   Movie movie=null;
		JTable jTable;    
	    MovieTableSelectionListener(JTable table) {
	        this.jTable = table;
	        movie=new Movie();
	    }
	    @Override
	    public void valueChanged(ListSelectionEvent e) {
	        	int index = jTable.getSelectedRow();
	        	int columns=jTable.getColumnCount();
	        	
	        	if(index!=-1&&columns==10)
	        	{
	        		try {
	        			movie.setMv_id(Integer.parseInt((String)jTable.getValueAt(index, 0)));
			        	movie.setName((String)jTable.getValueAt(index,1));
			        	movie.setScore(Float.parseFloat((String)jTable.getValueAt(index,2))); ;
						movie.setDirector((String)jTable.getValueAt(index,3));
						movie.setActor((String)jTable.getValueAt(index,4)) ;
						movie.setType((String)jTable.getValueAt(index,5)) ;
						movie.setTime((String)jTable.getValueAt(index,6)) ;
						movie.setDate(Integer.parseInt((String)jTable.getValueAt(index, 7)));
						movie.setIntroduction((String)jTable.getValueAt(index,8));
						movie.setImg((String)jTable.getValueAt(index,9));
						Employee_MainUITmpl.movie=new Movie();
						Employee_MainUITmpl.movie=movie;
						System.out.println(movie.getName());
					} catch (Exception e2) {
						// TODO: handle exception
					}
	        		
	        	}
	        	
	    }
	    
		

	}
	 class CustomerTableSelectionListener implements ListSelectionListener {
	    JTable jTable;
	     Customer customer;
	    CustomerTableSelectionListener(JTable table) {
	        this.jTable = table;
	        customer=new Customer();
	    }
	    @Override
	    public void valueChanged(ListSelectionEvent e) {
	        	int index = jTable.getSelectedRow();
	        	int columns=jTable.getColumnCount();
	        	if(index!=-1&&columns==8)
	        	{
	        		try {
	        			customer.setCustomer_id(Integer.parseInt((String)jTable.getValueAt(index, 0)));
			        	customer.setCustomer_name((String)jTable.getValueAt(index,1));
			        	customer.setCustomer_sex((String)jTable.getValueAt(index,2));
			        	customer.setCustomer_tel((String)jTable.getValueAt(index,4));
			        	customer.setCustomer_count((String)jTable.getValueAt(index,5));
			        	customer.setCustomer_password((String)jTable.getValueAt(index,6));
						customer.setCustomer_level((String)jTable.getValueAt(index,7));
						Employee_MainUITmpl.customer=new Customer();
						Employee_MainUITmpl.customer=customer;
						System.out.println(customer.getCustomer_count());
					} catch (Exception e2) {
						// TODO: handle exception
					}
		        
	        	}
	    }
	    
		

	}
	 class EmployeeTableSelectionListener implements ListSelectionListener {
	    JTable jTable;
	     Employee employee=null;
	    EmployeeTableSelectionListener(JTable table) {
	        this.jTable = table;
	        employee=new Employee();
	    }
	    @Override
	    public void valueChanged(ListSelectionEvent e) {
	        	int index = jTable.getSelectedRow();
	        	int columns=jTable.getColumnCount();
	        	if(index!=-1&&columns==6)
	        	{
	        		try {
	        			employee.setId(Integer.parseInt((String)jTable.getValueAt(index, 0)));
			        	employee.setAccess((String)jTable.getValueAt(index,1));
			        	employee.setName((String)jTable.getValueAt(index,2));
			        	employee.setPassword((String)jTable.getValueAt(index,3));
			        	employee.setcName((String)jTable.getValueAt(index,4));
			        	employee.setTel((String)jTable.getValueAt(index,5));
			        	Employee_MainUITmpl.employee=new Employee();
			        	Employee_MainUITmpl.employee=employee;
			        	System.out.println(employee.getAccess());
					} catch (Exception e2) {
						// TODO: handle exception
					}
		        	
	        	}
	    }
		

	}
	 class StudioTableSelectionListener implements ListSelectionListener {
	    JTable jTable;
	     Studio studio=null;
	    StudioTableSelectionListener(JTable table) {
	        this.jTable = table;
	        studio=new Studio();
	    }
	    @Override
	    public void valueChanged(ListSelectionEvent e) {
	        	int index = jTable.getSelectedRow();
	        	int columns=jTable.getColumnCount();
	        	if(index!=-1&&columns==6)
	        	{
	        		try {
	        			studio.setID(Integer.parseInt((String)jTable.getValueAt(index, 0)));
			        	studio.setName((String)jTable.getValueAt(index,1));
			        	studio.setRowCount(Integer.parseInt((String)jTable.getValueAt(index, 2)));
			        	studio.setColCount(Integer.parseInt((String)jTable.getValueAt(index, 3)));
			        	studio.setSeatnumber(Integer.parseInt((String)jTable.getValueAt(index,4)));
			        	studio.setIntroduction((String)jTable.getValueAt(index,5));
			        	Employee_MainUITmpl.studio=new Studio();
			        	Employee_MainUITmpl.studio=studio;
			        	System.out.println(studio.getName());
					} catch (Exception e2) {
						// TODO: handle exception
					}
	        		
	        	}
	        	
	        	
	    }
		

	}
	 class TicketTableSelectionListener implements ListSelectionListener {
		    JTable jTable;
		     Ticket ticket=null;
		     TicketTableSelectionListener(JTable table) {
		        this.jTable = table;
		        ticket=new Ticket();
		    }
		    @Override
		    public void valueChanged(ListSelectionEvent e) {
		        	int index = jTable.getSelectedRow();
		        	int columns=jTable.getColumnCount();
		        	if(index!=-1&&columns==8)
		        	{
		        		
		        		try {
		        			ticket.setTicket_id(Integer.parseInt((String)jTable.getValueAt(index, 0)));
		        			ticket.setMv_name((String)jTable.getValueAt(index, 1));
		        			ticket.setMv_time((String)jTable.getValueAt(index, 2));
		        			ticket.setSeat_row(Integer.parseInt((String)jTable.getValueAt(index, 3)));
		        			ticket.setSeat_col(Integer.parseInt((String)jTable.getValueAt(index, 4)));
		        			ticket.setPlay_time((String)jTable.getValueAt(index, 5));
		        			ticket.setStudio_name((String)jTable.getValueAt(index, 6));
		        			ticket.setPrice(Integer.parseInt((String)jTable.getValueAt(index, 7)));
		        			Employee_MainUITmpl.ticket=new Ticket();
				        	Employee_MainUITmpl.ticket=ticket;
				        	System.out.println(ticket.getTicket_id());
						} catch (Exception e2) {
							// TODO: handle exception
						}
		        		
		        	}
		        	
		        	
		    }
			
		}
}